package com.treemanage.treemanageback.controller;

import com.treemanage.treemanageback.pojo.Result;
import com.treemanage.treemanageback.pojo.Student;
import com.treemanage.treemanageback.service.StudentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController("/student")
@Slf4j
public class StudentController {

    @Resource
    private StudentService studentService;


    /**
     * 查询所有学生列表
     *
     * @param student 学生类
     * @return 所有学生信息
     */
    @GetMapping("/all")
    public Result list() {
        log.info("查询所有学生信息");
        List<Student> list = studentService.list();
        return Result.success(list);
    }

    /**
     * 通过id查询学生信息
     *
     * @param id 学生id
     * @return 单个学生信息
     */
    @PostMapping("/{id}/info")
    public Result findStudentById(@PathVariable String id) {
        return Result.success();
    }

    /**
     * 更新学生信息
     *
     * @param student 传入整个学生对象
     * @return 更新结果
     */
    @PutMapping("/update")
    public Result updateStudent(@RequestBody Student student) {
        return null;
    }

    /**
     * 删除学生信息
     *
     * @param id 学生id
     * @return 是否删除成功
     */
    @DeleteMapping("delete/{id}")
    public Result delete(@PathVariable Integer id) {
        return null;
    }
}
